﻿@{
    ViewBag.Title = "FindTrainnumberInfor";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<script src="~/Scripts/jquery-1.8.2.min.js"></script>
<script>

   
    $(function () {
        var url = location.search;
        var str = url.substr(4);
        var id = str;
        alert(id);
        $.ajax({
            type: 'get',
            url: '/Astart/Eidt_show',
            data: {
                Trainnumberid: id
            },
            success: function (d) {
                $(d).each(function (i, obj) {
                    $("#Table_show").append("<tr><td>车次名称</td><td><input type='text' id='Trainname' value=" + obj.Trainname + " /></td></tr>");
                    $("#Table_show").append("<tr><td>出发时间</td><td><input type='text' id='Starttime' value=" + obj.Starttime + " /></td></tr>");
                    $("#Table_show").append("<tr><td>抵达时间</td><td><input type='text' id='Endtime' value=" + obj.Endtime + " /></td></tr>");
                    $("#Table_show").append("<tr><td>经停站</td><td><input type='text' id='Stop' value=" + obj.Stop + " /></td></tr>");
                    $("#Table_show").append("<tr><td>经停时间</td><td><input type='text' id='Stoptime' value=" + obj.Stoptime + " /></td></tr>");
                    $("#Table_show").append("<tr><td>运行时间</td><td><input type='text' id='operation' value=" + obj.operation + " /></td></tr>");
                    $("#Table_show").append("<tr><td>车票剩余量</td><td><input type='text' id='Farenumber' value=" + obj.Farenumber + " /></td></tr>");
                    $("#Table_show").append("<tr><td><a href='#' onclick='Eidt_Do("+id+")'>修改</a></td></tr>");           
                })
            }
        })
     
    })

    function Eidt_Do(id)
    {
      
        var Trainname = $("#Trainname").val();
        var Starttime = $("#Starttime").val();
        var Endtime = $("#Endtime").val();
        var Stop = $("#Stop").val();
        var Stoptime = $("#Stoptime").val();
        var operation = $("#operation").val();
        var Farenumber = $("#Farenumber").val();

        $.ajax({
            type: "get",
            url: "/Astart/UpdateTrainnumberInforDo",
            data: {
                Trainnumberid: id,
                Trainname: Trainname,
                Starttime: Starttime,
                Endtime: Endtime,
                Stop: Stop,
                Stoptime: Stoptime,
                operation: operation,
                Farenumber: Farenumber
            },
            success: function (data) {
                if (data > 0) {
                    alert("修改成功");
                    location.href = '/Astart/TrainMenage';
                }
                else {
                    alert("修改失败");
                }
            }
        })
    }
    $(function () {
        $("#btn").click(function () {
           
        })
    })
</script>

<ul id="myTab" class="nav nav-tabs" style="margin-top:50px">
    <li class="active">
        <a href="#home" data-toggle="tab">
            修改车次信息
        </a>
    </li>
</ul>
<div id="myTabContent" class="tab-content">
    <div class="tab-pane fade in active" id="home">
        <table id="Table_show">  
                       
        </table>
    </div>

</div>